package com.liyong.pullorder.channels.auth;

import org.springframework.http.HttpHeaders;

import java.util.Map;

public class ApiKeyAuthStrategy implements AuthStrategy {
    @Override
    public String getType() { return "API_KEY"; }

    @Override
    public void apply(HttpHeaders headers, Map<String, String> config) {
        String header = config.getOrDefault("header", "Authorization");
        String prefix = config.getOrDefault("prefix", "ApiKey ");
        String apiKey = config.get("apiKey");
        if (apiKey != null) {
            headers.add(header, prefix + apiKey);
        }
    }
}